﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SerializedData;

namespace KnowledgeBaseManager
{
    public partial class AddManualCommandToState : Form
    {
        private DataCollection mDataCollection = DataCollection.Instance;
        private List<SCommand> mCommands;
        private SState mState;

        public AddManualCommandToState(SState state)
        {
            InitializeComponent();
            mCommands = mDataCollection.getCommandPool();
            mState = state;

            listViewO.Clear();
            listViewO.BeginUpdate();
            listViewO.Columns.Add("CID", 50);
            listViewO.Columns.Add("Name", 200);
            listViewO.Columns.Add("Description", 150);

            foreach (SCommand command in mDataCollection.getCommandPool())
            {
                ListViewItem oneRow = listViewO.Items.Add("" + command.getId());
                oneRow.SubItems.Add(command.getName());
                oneRow.SubItems.Add(command.getDescription());
                oneRow.Checked = mState.containsManualCommandWithId(""+command.getId());

            }
            listViewO.EndUpdate();





        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            mState.removeAllManualCommands();
            foreach (ListViewItem item in listViewO.CheckedItems)
            {
                mState.addManualCommandById(item.Text);
            }
            ((CState)this.Owner).refreshAll();
            this.Close();
        }

        private void CommandsBox_Enter(object sender, EventArgs e)
        {

        }

        private void AddManualCommandToState_Load(object sender, EventArgs e)
        {

        }
    }
}
